<template>
  <div>
     <breadcrumb></breadcrumb>
    <!-- 搜索表单 -->
    <!-- @submit.native.prevent停止默认行为 @submit是提交-->
    <el-form :inline="true" class="demo-form-inline"  @submit.native.prevent>
      <el-form-item label="姓名">
        <el-input v-model="name"  placeholder="请输入演员姓名" @keyup.native.enter="liststoreByName"></el-input>
      </el-form-item>
      <el-form-item>
        <!-- 点击回车 -->
        <el-button type="primary" @click="liststoreByName"  >查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 分割线 -->
    <el-divider content-position="left">未审核列表</el-divider>
    

    <br>
    <!-- 分页 -->
    <el-pagination
      background
      :total=store.total
      :page-size=store.pagesize
      layout=" ->,prev, pager, next,total,jumper"
      @current-change="ChangCurrentPage"
    >
    </el-pagination>

 
    
  </div>
</template>

<script>
import breadcrumb from "../components/breadcrumb.vue";
import httpApi from "@/http";
  export default {
    components: { breadcrumb},
     data(){
        return{
          name:'',
          store:{
            page: 1,
            pagesize:5,
            result:[],
            total:1
          },
          imgnone: true,
        }
     },
     methods:{
      // 删除店铺列表
      DeleteItem(store_id){
        // 弹窗
        this.$confirm('此操作将永久删除用户信息, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          
          // 确定
          // httpApi.storeApi.deletestoreById({store_id}).then(res =>{
          //   if(res.data.code == 200){
          //      console.log("删除成功",res);
          //     // 提醒用户删除成功
          //     this.$message({ type: 'success', message: '删除成功!' });
          //     // 刷新
          //     this.search()
          //   }else{
          //     // 提醒用户删除失败
          //     this.$message.error('错了哦，删除失败');
          //   }
           
          // })
        }).catch(() => {
            this.$message({ type: 'info', message: '已取消删除' });          
          });
        },

        // 点击查询按钮后执行，需要判断输入框中是否有关键字
        //trim()是去掉字符串两端的空格
        search(){
          if(this.name.trim() == ''){
            //当无输入值
            this.liststore()
          }else{
            //有输入值
            this.liststoreByName()
            
          }
        },


        // 封装店铺列表
        liststore(){
          // let url = "http://localhost:3000/store/list?page=1&pagesize=100"
          let params = {page: this.store.page ,pagesize: this.store.pagesize}
          httpApi.storeApi.queryAllStoreList(params).then(res =>{
            console.log("店铺列表",res);
            this.store = res.data.data
            if(this.store.result.img == /^(https[^"]*)"/){
              imgnone = false
            }
          })
        },
         //变化当前页
         ChangCurrentPage(page){
            // console.log("当前页数",page);
            this.store.page = page
            this.search()
        },

        // 通过昵称关键字查询演员列表
        liststoreByName(){
          let params = {Chinese:this.name.trim(),page:this.store.page, pagesize: this.store.pagesize}
            httpApi.storeApi.queryStoreByNameLike(params).then(res =>{
              console.log("店铺模糊查询",res);
              this.store = res.data.data
              if(this.store.result.img == /^(http[^"]*)"/){
                imgnone = false
              }
            })     
          }
        },

      // 页面挂载完毕后，发送请求，加载列表数据
      mounted(){
        //页面挂在完毕后，发送请求，加载列表数据
        this.liststore()
      }
  }
</script>

<style lang="scss" scoped>

</style>